package com.lzy.cloud.job.quartz;

import com.lzy.cloud.job.config.ApplicationContextUtil;
import com.lzy.cloud.job.utils.RemoteUtil;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.stereotype.Component;

@Component
public class BaseJob implements Job {

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        JobDataMap dataMap = context.getJobDetail().getJobDataMap();
        String serverUrl = dataMap.getString("server-url");
        String method = dataMap.getString("server-method");
        RemoteUtil remoteUtil = (RemoteUtil) ApplicationContextUtil.getBean("remoteUtil");
        remoteUtil.remoteJob(serverUrl, method);
    }

}
